-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add benchmarks for specialization #9752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bench-run/src/main/scala/dotty/tools/benchmarks/specialization/Functions.scala
Outdated
Show resolved
Hide resolved
bench-run/src/main/scala/dotty/tools/benchmarks/specialization/Functions.scala
Outdated
Show resolved
Hide resolved
bench-run/src/main/scala/dotty/tools/benchmarks/specialization/Functions.scala
Outdated
Show resolved
Hide resolved
…/Functions.scala Co-authored-by: Nicolas Stucki <[email protected]>
…/Functions.scala Co-authored-by: Nicolas Stucki <[email protected]>
82d8be6
to
cdc14b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring
// remove it will result in 200x speed up | ||
arrByName(1) = null | ||
arrByName(0).foo(6) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out we also need this turnaround to defeat JVM optimization.
8502ffb
to
62339a0
Compare
inline def times(inline work: Int): Int = { | ||
var res = 0 | ||
var count = 0 | ||
while count < x do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked what is being done here exactly but note that it's not recommended to use loops when benchmarking on the JVM: http://tutorials.jenkov.com/java-performance/jmh.html#writing-good-benchmarks, instead let JMH run things as many times as needed to get good statistics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder, @smarter . It's really subtle to defeat optimization in microbenchmarks.
Add benchmarks for specialization